package com.lzw.service.impl.superAdmin;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lzw.mapper.superAdmin.ProblemMedicineManageMapper;
import com.lzw.pojo.Admins;
import com.lzw.pojo.ProblemMedicine;
import com.lzw.pojo.StockEntries;
import com.lzw.service.superAdmin.ProblemMedicineManageService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class ProblemMedicineManageServiceImpl implements ProblemMedicineManageService {

    @Autowired
    private ProblemMedicineManageMapper problemMedicineManageMapper;


    @Override
    public List<ProblemMedicine> list(Integer pageNum, Integer pageSize, LocalDate reportedDate, String medicine) {
        PageHelper.startPage(pageNum,pageSize);
        List<ProblemMedicine> list = problemMedicineManageMapper.list(reportedDate,medicine);
        Page<ProblemMedicine> problemMedicines = (Page<ProblemMedicine>) list;
        return problemMedicines;
    }

    @Override
    public void delete(List<Integer> ids) {
        problemMedicineManageMapper.delete(ids);
    }

    @Override
    public void add(ProblemMedicine problemMedicine) {
        problemMedicine.setReportedDate(LocalDate.now());
        problemMedicineManageMapper.add(problemMedicine);
    }

    @Override
    public void update(ProblemMedicine problemMedicine) {
        problemMedicineManageMapper.update(problemMedicine);
    }
}
